package me.yobol.lintcode.naive.countlinkedlist;

import me.yobol.lintcode.ListNode;

/**
 *
 * @author Yobol
 */
public class CountLinkedList implements ICountLinkedListNodes{

    @Override
    public int countNodes(ListNode head) {
        if (head == null) {
            return 0;
        }
        ListNode current = head;
        int counter = 0;
        while (current != null) {
            counter++;
            current = current.next;
        }
        return counter;
    }
    
}
